package com.yonyou.crm.sys.dynamic.builder;

import net.sf.json.JSONObject;

public class Field {
	
	private String title;
	private Link link;
	
	public Field() {
		super();
	}
	
	public Field(String title) {
		super();
		this.title = title;
	}
	public Field(String title,Link link) {
		super();
		this.title = title;
		this.link = link;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public Link getLink() {
		return link;
	}
	public void setLink(Link link) {
		this.link = link;
	}
	
	public JSONObject toJSONObject() {
		JSONObject json = new JSONObject();
		json.put("title", title);
		if(link != null) {
			json.put("link", link.toJSONObject());
		}
		return json;
	}
	
	public boolean equals(Field f) {
		if(link != null && f.link != null) {
			return link.equals(f.link);
		}
		return title.equals(f.title);
	}
}
